<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/jquery.fancybox.css" />
<link rel="stylesheet" type="text/css"
	href="css/helpers/jquery.fancybox-thumbs.css" />
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/jquery.mousewheel-3.0.6.pack.js"></script>
<script type="text/javascript" src="js/jquery.fancybox.js"></script>
<script type="text/javascript"
	src="js/helpers/jquery.fancybox-thumbs.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.zclip.min.js"></script>

<script type="text/javascript" src="js/page.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<!-- <script type="text/javascript" src="js/show_pic.js"></script> -->
<title>动态管理</title>
</head>
<body>
	<jsp:include page="navigation.jsp"></jsp:include>
	<div class="container" style="margin-left: 190px;">
		<div class="topbar-inner">
			<div class="myhead">
				<span class="crumb-name">动态管理</span>
			</div>
		</div>
		<form id="pageForm" action="momentinfo" method="post">
			<input type="hidden" value="${ page.pageCount }" id="pageCount"
				name="pageCount" /> <input type="hidden"
				value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
		</form>
		<div style="margin: 20px 20px 20px 20px; text-align: center;">
			<table class="table table-bordered table-hover table-striped">
				<thead>
					<tr>
						<th>发布者</th>
						<th>昵称</th>
						<th>头像</th>
						<th>发布内容</th>
						<th>发布图片/视频</th>
						<th>发布时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${ list }" var="l">
						<tr>
							<td><a href="userdetail?userid=${ l.user.id }">${ l.user.user_name }</a></td>
							<td>${ l.user.appellation }</td>
							<td><c:if
									test="${ l.user.portrait == null || l.user.portrait == '' }">
									<img src="images/defalut.png" />
								</c:if> <c:if
									test="${ l.user.portrait != null && l.user.portrait != '' }">
									<img
										src="http://139.196.188.251:8080/upload/cache/${ l.user.portrait }"
										width="50px" />
								</c:if></td>
							<td><c:if test="${fn:length(l.content) > 25}">${fn:substring(l.content, 0, 23)}...</c:if>
								<c:if test="${fn:length(l.content) <= 25}">${ l.content }</c:if>
							</td>
							<td><c:if test="${ l.video != null && l.video != '' }">
									<div class="input-group">
										<input type="text" class="form-control"
											value="http://139.196.188.251:8080/upload/${ l.video }" /> <img
											class="copy_img" src="images/copy.png"
											style="cursor: pointer; border-top: 1px solid #CCC; border-bottom: 1px solid #CCC; border-right: 1px solid #CCC; border-top-right-radius: 5px; border-bottom-right-radius: 5px;"
											width="34px" height="34px" data-toggle="poppver" title="点击复制"
											data-placement="top" data-content="点击复制" />

<%-- 										<button type="button" id="showvideo" onclick="showvideo('http://139.196.188.251/upload/${ l.video }')" --%>
<!-- 											class="btn btn-default" -->
<!-- 											style="margin-left: 20px; margin-top: 1px;">查看视频</button> -->
									</div>
								</c:if>
								<c:if test="${ l.video == null || l.video == '' }">

									<c:if test="${ l.pics != null && l.pics != '' }">
										<c:set var="pics" value="${fn:split(l.pics, ',') }" />
										<c:forEach items="${ pics }" var="p">
											<%-- 											<a class="fancybox-thumbs" data-fancybox-group="thumb" href="http://139.196.188.251/upload/origin/${ p }"><img src="http://139.196.188.251/upload/origin/${ p }" alt="" width="50px" height="50px"  /></a> --%>
											<img src="http://139.196.188.251:8080/upload/origin/${ p }"
												width="50px" height="50px" />
										</c:forEach>
									</c:if>
								</c:if></td>
							<td><fmt:formatDate value="${ l.create_time }"
									pattern="yyyy-MM-dd HH:mm:ss" type="date" dateStyle="long" /></td>
							<td>
<%-- 							<c:if test="${ l.status == 1 }"> --%>
<!-- 								已警告 -->
<%-- 								</c:if>  --%>
								<c:if test="${ l.status == 2 }">
								已删除
								</c:if> 
								<c:if test="${ l.status == 0 }">
<%-- 									<a href="javascript:" onclick="toWarn(${ l.id })">警告</a> --%>
								<a href="javascript:"onclick="toDelete(${ l.id })">删除</a>
								</c:if>
								&emsp;|&emsp;
								<c:if test="${ l.chioce == 0 }">
								<a href="javascript:" onclick="toChioce(${ l.id },'你确定要加入精选？')">加入精选</a>
								</c:if>
								<c:if test="${ l.chioce == 1 }">
								<a href="javascript:" onclick="toChioce(${ l.id },'你确定要取消精选？')">取消精选</a>
								</c:if>
								</td>
						</tr>
					</c:forEach>

				</tbody>
			</table>
			<input type="hidden" value="${ page.pageCount }" id="pageCount"
				name="pageCount" /> <input type="hidden"
				value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
			<c:if test="${ page == null }">
				<div style="font-size: larger;">暂无数据</div>
			</c:if>
			<c:if test="${ page != null && page.pageCount > 1 }">
				<ul id="pagination" class="pagination">

				</ul>
				<script type="text/javascript">
					setPage(document.getElementById("pagination"), parseInt($(
							"#pageCount").val()), parseInt($("#pageIndex")
							.val()));
				</script>
			</c:if>
		</div>
	</div>

	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel"
		aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close"
						data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">提示信息：</h4>
				</div>
				<div class="modal-body">
					<form id="modalForm" action="/promptmessage"
						method="post">
						<input type="hidden" id="prompt_type"
							class="form-control" name="prompt_type" /> <input
							type="hidden" id="id" class="form-control" name="id" />
						<div id="user_name_id"
							style="width: 100%; height: height: auto;">
							<textarea name="prompt_message"
								style="margin: 0 31px; width: 500px; height: 300px; border-radius: 8px; border: 1px solid; resize: none; outline: none;"
								id="prompt_message"
								onblur="if (value == '') {value = '请输入提示信息！'}"
								onfocus="if (value == '请输入提示信息！') { value = '' }">请输入提示信息！</textarea>
						</div>
						<div class="modal-footer"
							style="border-top: 0px solid #e5e5e5">
							<button type="button" class="btn btn-default"
								data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-primary"
								id="sub_btn" onclick="toPrompt()">提交</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<!-- /.modal -->

	<script>
		$(function() {
			$('.submenu_6_1').addClass('submenu_native');

			$('td>img').click(function() {
				$('.show_big>img').prop('src', $(this).prop('src'));
				$('.show_big').css('display', 'block');
				$('.show_big').focus();
			});
			$('.show_big').focus(function() {
				alert('asdfasdfadsf');
				$(this).css('display', 'none');
			});
			$('.show_big').blur(function() {
				alert('asdfasdfadsf');
				$(this).css('display', 'none');
			});
			
// 			$('.copy_img').click(function() {
// 				toCopyBlank($(this).parent().find('input').val());
// 				$('.copy_img').prop('title', '点击复制');
// 				$(this).prop('title', '已复制');
// 			});
				$(".copy_img").zclip({  
	                path:'http://img3.job1001.com/js/ZeroClipboard/ZeroClipboard.swf',  
	                copy:function(){return $(this).parent().find('input').val()},  
	                afterCopy:function(){alert('复制成功！');}  
	            });
			
			$('[data-toggle=popover]').popover();
			
			$('.fancybox-thumbs').fancybox({
				prevEffect : 'none',
				nextEffect : 'none',

				closeBtn  : false,
				arrows    : false,
				nextClick : true,

				helpers : {
					thumbs : {
						width  : 50,
						height : 50
					}
				}
			});

		});
		function toWarn(id) {
			$("#myModal").modal('show');
			$('#prompt_type').val(1);
			$('#id').val(id);
		}
		function toDelete(id) {
			$("#myModal").modal('show');
			$('#prompt_type').val(2);
			$('#id').val(id);
		}
		function toPrompt() {
			var prompt_message = $('#prompt_message').val();
			if (prompt_message != null && prompt_message) {
				$.ajax({
					type: 'post', 
					url: 'promptmessage', 
					data: $('#modalForm').serialize(), 
					success: function(data) {
						if (data.code == 0) {
							alert('操作成功！');
							window.location.reload();
						} else {
							alert('操作失败！');
							window.location.reload();
						}
					}
				});
			} else {
				alert('提示信息不能为空！');
			}
		}
		
		function toDetail(id) {
			window.location.href = 'momentdetail?id=' + id;
		}
		
		function toCopyBlank(txt) {
			if (window.clipboardData ) {  
	            $('.copy_img').click(function() {  
	                window.clipboardData.setData("Text", txt);  
	                alert('复制成功！');  
	            });  
	        } else {  
	            $(".copy_img").zclip({  
	                path:'http://img3.job1001.com/js/ZeroClipboard/ZeroClipboard.swf',  
	                copy:function(){return txt},  
	                afterCopy:function(){alert('复制成功！');}  
	            });  
	        }
			
		}
			function showvideo(src) {
				$('#videosrc').prop('src', src);
				$("#myModal").modal('show');
			}
		
			function toChioce(id, message) {
				if (confirm(message)) {
					$.ajax({
						type : 'post',
						url : 'setchioce',
						data : {id: id},
						success : function(data) {
							console.log(data);
							if (data != null) {
								if (data.code == 0) {
									alert('操作成功！');
									window.location.reload();
								} else {
									alert(data.message);
								}
							}
						}
					});
				}
				
			}
	</script>
</body>

</html>